using System;
using System.Collections.Generic;

namespace MatrixFramework.Shared.Contracts.Monitoring
{
    /// <summary>
    /// OpenTelemetry配置选项
    /// 符合ABP vNext规范
    /// </summary>
    public class OpenTelemetryOptions
    {
        /// <summary>
        /// 是否启用OpenTelemetry
        /// </summary>
        public bool Enabled { get; set; } = true;

        /// <summary>
        /// 服务名称
        /// </summary>
        public string ServiceName { get; set; } = string.Empty;

        /// <summary>
        /// 服务版本
        /// </summary>
        public string ServiceVersion { get; set; } = "1.0.0";

        /// <summary>
        /// 资源配置
        /// </summary>
        public ResourceConfiguration Resource { get; set; } = new();

        /// <summary>
        /// Prometheus配置
        /// </summary>
        public PrometheusConfiguration Prometheus { get; set; } = new();

        /// <summary>
        /// 追踪配置
        /// </summary>
        public TracingConfiguration Tracing { get; set; } = new();
    }

    /// <summary>
    /// 资源配置
    /// </summary>
    public class ResourceConfiguration
    {
        /// <summary>
        /// 服务名称
        /// </summary>
        public string ServiceName { get; set; } = string.Empty;

        /// <summary>
        /// 服务版本
        /// </summary>
        public string ServiceVersion { get; set; } = "1.0.0";

        /// <summary>
        /// 部署环境
        /// </summary>
        public string DeploymentEnvironment { get; set; } = "Development";

        /// <summary>
        /// 自定义属性
        /// </summary>
        public Dictionary<string, object> CustomAttributes { get; set; } = new();
    }

    /// <summary>
    /// Prometheus配置
    /// </summary>
    public class PrometheusConfiguration
    {
        /// <summary>
        /// 是否启用Prometheus
        /// </summary>
        public bool Enabled { get; set; } = true;

        /// <summary>
        /// 指标端点
        /// </summary>
        public string Endpoint { get; set; } = "/metrics";

        /// <summary>
        /// 指标前缀
        /// </summary>
        public string MetricsPrefix { get; set; } = string.Empty;
    }

    /// <summary>
    /// 追踪配置
    /// </summary>
    public class TracingConfiguration
    {
        /// <summary>
        /// 是否启用追踪
        /// </summary>
        public bool Enabled { get; set; } = true;

        /// <summary>
        /// 采样概率
        /// </summary>
        public double SampleProbability { get; set; } = 0.1;

        /// <summary>
        /// 包含的源
        /// </summary>
        public List<string> IncludeSources { get; set; } = new()
        {
            "Microsoft.AspNetCore",
            "System.Net.Http",
            "Volo.Abp"
        };
    }
}